<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <th:block th:include="include :: header('登录')"/>
    <style>
        html{
            height: 100%;
        }
        body{
            height: 100%;
            background-color: #ede7e4;
            background-image: image('static/images/backColor.png');
        }
        .layui-form {
            padding: 15% 30% 15%;
        }
        .layui-btn {
            width: 100%;
        }
        .layui-input-block {
            margin-left: 28%;
        }
        .fr{
            margin-left: 78%;
        }
    </style>
</head>
<body>
<div style="height: 100%">
    <h1 style="margin-top: 5%;text-align: center;">酒店管理系统登录</h1>
    <form class="layui-form">
        <div class="layui-form-item">
            <input type="text" name="username" required lay-verify="required" placeholder="用户名" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-item">
            <input type="password" name="password" required lay-verify="required" placeholder="密码" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-item login-btn">
            <button lay-submit lay-filter="login" type="button" onclick="login()" class="layui-btn">登录</button>
        </div>
        <hr/>
        <p><a href="/admin/toRegister" class="fl">立即注册</a><a href="javascript:;" class="fr">忘记密码？</a></p>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script>
    function login(){
        $.post(ctxPath+'/admin/login',$("form").serialize(),function (res) {
            if(res.code === 200){
                window.location.href = ctxPath+'/admin/index'
            }else{
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.msg(res.msg);
                });
            }
        });
    }
    layui.use('form', function () {
        var form = layui.form;
        return false;
    });
</script>
</body>
</html>
